from typing import List


def quick_sort(arr: List):
    if len(arr) < 2:
        return arr
    index = len(arr) // 2
    pivot = arr[index]
    less = [arr[i] for i in range(0, len(arr)) if arr[i] < pivot]
    greater = [arr[i] for i in range(0, len(arr)) if arr[i] > pivot]
    return quick_sort(less) + [pivot] + quick_sort(greater)


if __name__ == '__main__':
    nums = [2, 3, 1, 5, 6, 8, 7, 4]
    print(quick_sort(nums))
